package com.lingxu.module.collection.controller;

import com.lingxu.module.collection.entity.ReportVo;
import com.lingxu.module.collection.service.IReportRunService;
import com.lingxu.module.collection.service.IReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;


@Slf4j
@Api(tags="模型报告")
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private IReportService reportService;
    @Autowired
    private IReportRunService reportRunService;

    //报告下载主模型及其子模型合计
    @ApiOperation(value = "模型报告-导出报告", notes = "模型报告-导出报告")
    @RequestMapping("/exportReport")
    public void exportReport(ReportVo vo, HttpServletResponse response,String timestamp){
        reportService.exportReport(vo,response,timestamp);
    }

    //从运行记录下载指定模型报告（单个）
    @RequestMapping(value = "/exportReportByRun")
    public void exportReportByRun(ReportVo vo,HttpServletResponse response){
        reportRunService.exportReportByRun(vo,response);
    }

    @Scheduled(cron = "0 0 2 1 * ?")
    public void restReportNo(){
        reportService.restReportNo();
    }
}
